import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(10)
    const doubleCount = computed(() => count.value * 2)
    const num1 = ref(111)
    const num2 = ref(2222)
    const num3 = ref(33333)

    const increment = () => {
      count.value++
    }

    const decrement = () => {
      count.value--
    }

    return {
      count,
      doubleCount,
      num1,
      num2,
      num3,
      increment,
      decrement,
    }
  },
  {
    // 配置持久化
    // persist: true, // 持久化return出来的所有属性
    // 持久化一部分属性
    persist: {
      paths: ['count'],
    },
  }
)
